package com.googlecode.flair.builder
{
	import com.googlecode.flair.IFlairComponent;
	
	import mx.collections.ArrayCollection;
	import mx.collections.ICollectionView;
	import mx.controls.treeClasses.ITreeDataDescriptor;

	public class FlairDesignerOutline implements ITreeDataDescriptor
	{
		public function FlairDesignerOutline()
		{
		}

		public function getChildren(node:Object, model:Object=null):ICollectionView
		{
			if (node is IFlairComponent) {
				var components : ArrayCollection = IFlairComponent(node).components;
				return components;
			}
			return null;
		}
		
		public function hasChildren(node:Object, model:Object=null):Boolean
		{
			if (node is IFlairComponent) {
				var components : ArrayCollection = IFlairComponent(node).components;
				return components != null && components.length > 0;
			}
			return false;
		}
		
		public function isBranch(node:Object, model:Object=null):Boolean
		{
			return hasChildren(node, model);
		}
		
		public function getData(node:Object, model:Object=null):Object
		{
			return node;
		}
		
		public function addChildAt(parent:Object, newChild:Object, index:int, model:Object=null):Boolean
		{
			return true;
		}
		
		public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean
		{
			return true;
		}
		
	}
}